package com.hp.bon.sgw.wh.channel.groupConsistency.BizSlot;

import com.hp.bon.sgw.wh.channel.common.BizConsts;
import com.hp.bon.sgw.wh.channel.common.BizParam;
import com.hp.bon.sgw.wh.channel.common.BizResult;
import com.hp.bon.sgw.wh.channel.invoices.BizSlot;
import com.hp.bon.sgw.wh.channel.invoices.bizSlot.HttpClientUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @PROJECT_NAME: SGW_WH2.1_TMALL
 * @DESCRIPTION:
 * @USER: YouQi
 * @DATE: 2021/5/20 16:45
 */
public class QryBalanceRecordDetailSlot implements BizSlot {
    private static final Logger _log = LoggerFactory.getLogger(QryBalanceRecordDetailSlot.class);
    @Override
    public BizResult doBiz(BizParam bizParam) {
        BizResult bizResult = new BizResult();
//        String method = bizParam.getParamString(BizConsts.KEY_REQUEST_METHOD);
//        String xAppId = bizParam.getParamString(BizConsts.RQUEST_HEADER_X_APP_ID);
//        String xAppKey = bizParam.getParamString(BizConsts.RQUEST_HEADER_X_APP_KEY);
        String reqBody = bizParam.getParamString(BizConsts.KEY_REQUEST_BODY);


        // 获取URL地址
        String url = bizParam.getParamString(BizConsts.KEY_ACCOUNT_API_URL);

        String respStr = HttpClientUtils.postHttpStr(reqBody, url,bizParam);


        if ("".equals(respStr)) {
            bizResult.setCode(BizConsts.STATUS_ACOUNT_API_FAIL);
            respStr=  HttpClientUtils.getErrorJsonStr(BizConsts.STATUS_ACOUNT_API_FAIL,"","","");
        }else {

            bizResult.setCode(BizConsts.STATUS_ACOUNT_API_SUCCESS);
        }
        _log.info("Responding to external messages====:{}",respStr);
        bizResult.setHttpBody(respStr);

        return bizResult;
    }
}
